import time

import uiautomator2 as u2
from adbutils import adb

# device_ip = 'e0edbd001403053'
device_1 = '398a062'
# device_1 = '322db21f'
# device_1 = '00000000d5328bbf'
# device_2 = '000000003749c193'
# device_3 = 'bc527fe4'
# device_ip = '10.10.113.54:5555'
d_one = u2.connect(device_1)
# d_one = u2.connect()
d_one_device = adb.device(serial=device_1)
# device_info = {"d_one": d_one, "d_two": d_two}
# adb_device = adb.device(serial=device_ip)
# adb_device.root()

if __name__ == '__main__':
    # adb_device.root()
    # adb_device.shell([r"sendevent /dev/input/event0 1 353 1", r"sendevent /dev/input/event0 0 0 0"])
    # adb_device.shell(r"sendevent /dev/input/event0 1 353 1")
    # res = adb_device.shell("< test.txt")
    # res = adb_device.shell("./data/test.sh")
    # res = adb_device.shell(
    #     "su & sendevent /dev/input/event0 1 353 1 & sendevent /dev/input/event0 0 0 0 & echo 'down' & sleep 3 & sendevent /dev/input/event0 1 353 0 & sendevent /dev/input/event0 0 0 0 & echo 'up'")
    # print(res)
    # res = d_one.app_current()
    # d_one(text="开启投屏").click()
    # print(res)
    # res = d_one.open_url(
    #     "iqiyi://com.qiyi.video.iv/player?command=QYSExecType.PAUSE")
    # res = d_one.open_url(
    #     "iqiyi://com.qiyi.video.iv/app?command=QYSExecType.SEARCH&param=速度与激情")

    # res = d_one.open_url(
    #     "iqiyi://com.qiyi.video.iv/driver?command=play_card_video&qipuId=406386200&albumId=0&channelId=1")
    # res = d_one.open_url(
    #     "iqiyi://com.qiyi.video.iv/driver?command=play_card_video&qipuId=8562017447924800&albumId=0&channelId=1&source=5D&scriptAddress=http://vehicle-file-stg.danghongyun.com/upload/2024/04/22/848395d5944f428fa80ef31004ca7dd9/8562017447924800.bin.yaml")
    # print(res)
    # res = d_one.open_url(
    #     "iqiyi://com.qiyi.video.iv/player?command=QYSExecType.SEEK&param=30000")
    # d_one.swipe_ext("left",box=())
    d_one(resourceId="com.android.systemui:id/button_single_icon").click()
    res=d_one(resourceId="com.android.systemui:id/button_single_icon").info
    print(res)
    # res=d_one(resourceId="com.android.systemui:id/car_bottom_bar").child(className="android.widget.FrameLayout").count
    # print(res)
    # d_one(resourceId="com.android.systemui:id/car_bottom_bar").child(className="android.widget.FrameLayout").click()

